package com.centaur0.tags;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;

import com.centaur0.util.Application;
import com.centaur0.util.ColorEnum;
import com.centaur0.util.LayoutSite;

public class GetAttributeTag extends SimpleTagSupport {
	private static final Object NAME_COR_PRINCIPAL    = "cor_principal";
	private static final Object NAME_COR_AZUL_ESCURO  = "cor_azul_escuro";
	private static final Object NAME_COR_SECUNDARIA   = "cor_secundaria";
	private static final Object NAME_COR_TERCEIRA     = "cor_terceira";
	private static final Object SITE_DESCRICAO        = "site_descricao";
	private static final Object SITE_SLOGAN           = "site_slogan";
	private String name;

	public String getName(){
		return this.name;
	}
	
	public void setName(String name){
		this.name = name;
	}
	
	@Override
	public void doTag() throws JspException, IOException {
		if(NAME_COR_PRINCIPAL.equals(name)){
			this.getJspContext().getOut().append(LayoutSite.getColorAsString(ColorEnum.AzulPrincipal));
		} else if(NAME_COR_SECUNDARIA.equals(name)){
			this.getJspContext().getOut().append(LayoutSite.getColorAsString(ColorEnum.AzulSecundario));
		} else if(NAME_COR_AZUL_ESCURO.equals(name)){
			this.getJspContext().getOut().append(LayoutSite.getColorAsString(ColorEnum.AzulEscuro));
		} else if(NAME_COR_TERCEIRA.equals(name)){
			this.getJspContext().getOut().append(LayoutSite.getColorAsString(ColorEnum.Laranja));
		} else if(SITE_DESCRICAO.equals(name)){
			this.getJspContext().getOut().append(Application.getHttpApplicationContext().getInitParameter("descricaoSite").toString());
		} else if(SITE_SLOGAN.equals(name)){
			this.getJspContext().getOut().append(Application.getHttpApplicationContext().getInitParameter("sloganSite").toString());
		}
	}
}
